﻿@using System.Text
@using OA.Model
@using OA.AspNetCore.Html
@using OA.Core.Model
@using OA.Core.Helper

@model PageList<SimpleKnowledge>
@{
    ViewBag.Title = "知识列表";
    Layout = "~/Areas/Member/Views/Shared/_Layout.cshtml";
}
<div class="layui-tab layui-tab-brief" lay-filter="user">
    <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 5px 0;">
        <form action="" class="layui-form">            
            <div class="layui-inline">
                <a class="layui-btn" href="javascript:ShowPage('/Management/RelatedCompany/AddContact?relatedCompanyID=@ViewBag.ID','添加联系人')">添加联系人</a>
            </div>
        </form>
    </div>
    <table class="layui-table" lay-data="{url:'GetContactData?id=@ViewBag.ID', cellMinWidth: 80, page: true,limit:10}" id="resultList" lay-filter="resultList">
        <thead>
            <tr>
                <th lay-data="{ field: 'Contacts',width:100}">联系人</th>
                <th lay-data="{width:120,field: 'Tel'}">电话</th>
                <th lay-data="{field:'Salutation', width:160}">称呼</th>
                <th lay-data="{field:'Position', width:150}">职务</th>                 
                <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#barDemo'}">操作</th>
            </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-primary layui-btn-xs" href="javascript:ShowPage('/Management/RelatedCompany/EditContact?id={{d.ID}}','编辑联系人')">编辑</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" href="javascript:DeleteItem({{d.ID}})">删除</a>
    </script>

</div>
<script type="text/javascript">
    function DeleteItem(id) {
        layer.confirm('您正在进行删除联系人操作', {
            btn: ['是的,我要删除该联系人', '不小心点错了'] //按钮
        }, function () {
            var url = "/Management/RelatedCompany/DeleteContact?cid=@ViewBag.ID&id=" + id;
            $.getJSON(url, function (data) {
                layer.msg(data.Msg);
                if (data.State === 200) {
                    $(".layui-laypage-btn")[0].click();
                }                 
            });
        }, function () {

        });
    }  
</script>


